<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>123</li>
        <li>123</li>
        <li>123</li>
        <li>123</li>
    </ul>
    <script>
        var li=document.querySelectorAll("li");
        for(i=0;i<li.length;i++){
            li[i].onclick=function (){
                this.style.color="red";
                console.log(1)
            }
        }
    </script>
</body>
</html>